//
//  HSLoginViewController.m
//  HSTS
//
//  Created by simon on 2017/1/23.
//  Copyright © 2017年 simon. All rights reserved.
//

#import "HSLoginViewController.h"
#import "HSRegisterViewController.h"
#import "AFNetworking.h"
#import "AppDelegate.h"

@interface HSLoginViewController ()
@property (weak, nonatomic) IBOutlet UITextField *userTF;
@property (weak, nonatomic) IBOutlet UITextField *passwordTF;
@property (weak, nonatomic) IBOutlet UIButton *loginBtn;
@property (weak, nonatomic) IBOutlet UIButton *registerBtn;

@end

@implementation HSLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    self.view.backgroundColor = [UIColor redColor];
    
    
    // Do any additional setup after loading the view from its nib.
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    HSUser * user = [HSUser standardUser];
    HSMUser * muser = user.user;
    if (muser.username && muser.password) {
        self.passwordTF.text    = muser.password;
        self.userTF.text        = muser.username;
    }

}

- (IBAction)loginClick:(id)sender {
    
    // 判断账号密码
    [self checkuotInfo];

    NSString * userNmae = self.userTF.text;
 
    [(AppDelegate *)APPDELEGATE showHomeScreenWithUser:nil];

  }
//点击登陆后的操作
- (void)loginWithUsername:(NSString *)username password:(NSString *)password
{
    
}

/**
    检查输入账号的信息
 */
- (void)checkuotInfo
{
    if ([self.userTF.text isEqualToString:@""]) { // 没有输入账号
        
        return;
    }else if ([self.passwordTF.text isEqualToString:@""]){ // 没有输入密码
    
        return;
    }
}

- (IBAction)registerBtn:(id)sender {
    HSRegisterViewController * vc =  [[HSRegisterViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
- (IBAction)deleteUsername:(id)sender {
    self.userTF.text = @"";
}
- (IBAction)deletePassword:(id)sender {
    self.passwordTF.text = @"";
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
